<template>
  <div class="get-address-page-main base-main bgcFFF">
    <iframe
      id="container"
      frameborder="0"
      src="https://apis.map.qq.com/tools/locpicker?search=1&type=1&radius=2000&total=10&key=Y42BZ-7WGKU-ENBVD-BMP4U-3BQSE-H2B5Q&referer=myapp">
    </iframe>
  </div>
</template>

<script type="text/ecmascript-6">
  export default {
    data() {
      return {
        value: '',
        longitude: '',//经度
        latitude: '',//纬度
      }
    },
    mounted() {
      this.init()
    },
    methods: {
      init(){
        let _this = this
        window.addEventListener('message', function(event) {
          // 接收位置信息，用户选择确认位置点后选点组件会触发该事件，回传用户的位置信息
          let loc = event.data;
          //防止其他应用也会向该页面post信息，需判断module是否为'locationPicker'
          if (loc && loc.module == 'locationPicker') {
            console.log('location', loc);
            window.localStorage.setItem('loc',JSON.stringify(loc))
            _this.$router.replace({
              name: 'addressEditor',
              replace: true
            })
          }
        }, false);
      },
    },
  }
</script>

<style scoped lang="scss">
 @import "../../assets/css/getAddPage.scss";
</style>
